<template>
	<view class="handling_result">
		<view class="result_box">
			<view class="result_item">结案条件：{{caseInfo.archivesTypeLeveThree.endsConditions}}</view>
			<view class="result_item">
				<view>处置后图片：</view>
				<uni-swiper-dot class="uni-swiper-dot-box" :mode="mode" :dots-styles="dotsStyles" field="content" v-if="small_images.length>0">
					<swiper class="swiper-box">
						<swiper-item v-for="(item, index) in small_images" :key="index">
							<view class="swiper-item">
								<image class="image" :src="item" mode="aspectFill" :draggable="false" @click="seeImages(index, big_images)" />
							</view>
						</swiper-item>
					</swiper>
				</uni-swiper-dot>
			</view>
			<view class="result_item">{{log_info.remark}}</view>
		</view>

		<!-- 机构处置人员-----处置按钮 -->
		<view class="pending_buttons">
			<button type="default" @click="eventDetails">案件详情</button>
			<button type="default" @click="managementCase">案件核查</button>
		</view>
	</view>
</template>

<script>
	import URL  from '@/util/url.js';
	import { getEventLogByEventIdAndTypeCodes } from '@/api/pending_cases.js'
	export default{
		data(){
			return {
				caseInfo: {},
				log_info: {},

				//轮播图
				mode: 'doc',
				dotsStyles:{
					backgroundColor: 'rgba(0, 0, 0, .3)',
					border: '1px rgba(0, 0, 0, .3) solid',
					color: '#fff',
					selectedBackgroundColor: 'rgba(0, 0, 0, .9)',
					selectedBorder: '1px rgba(0, 0, 0, .9) solid'
				},
				big_images: [],
				small_images: [],
			}
		},
		onLoad(options) {
			//获取传过来的案件信息
			this.caseInfo = JSON.parse(options.eventItem);
			//根据案件id及环节编码获取最新处理日志结果
			this.getEventLogByEventIdAndTypeCodes();
		},
		methods:{
			//案件核查
			managementCase(){
				uni.removeStorageSync('currentLocation');
				uni.navigateTo({
					url: '/pages/pending-cases/managementCase?gdx='+this.caseInfo.gdx+'&gdy='+this.caseInfo.gdy+'&eventId='+this.caseInfo.eventId + '&current_handing_type=6'
				})
			},
			//跳转到案件详情
			eventDetails(){
				uni.navigateTo({
					url: '/pages/my-task/eventDetails?eventItem='+ JSON.stringify(this.caseInfo)
				})
			},
			//根据案件id及环节编码获取最新处理日志结果
			getEventLogByEventIdAndTypeCodes(){
				getEventLogByEventIdAndTypeCodes({eventId: this.caseInfo.eventId}).then((res) => {
					if(res.data != null){
						if(res.code == 200){
							this.log_info = res.data;
							var images = JSON.parse(res.data.images);
							var small_images = [];
							var big_images = [];
							for(var i=0;i<images.length;i++){
								switch (images[i].size_type) {
									case '0':
										small_images.push(`${URL.CASEIMAGE_URL}${images[i].path}`);
										break;
									case '1':
										big_images.push(`${URL.CASEIMAGE_URL}${images[i].path}`);
										break;
								}
							}
							this.small_images = small_images;
							this.big_images = big_images;
						}else{
							this.$tip.toast(res.msg);
						}
					}
				}).catch((error) => {
				})
			},
			//案件列表查看大图
			seeImages(index, bigImgData){
				let _this = this;
				uni.previewImage({
					urls: bigImgData,
					current: index,
					longPressActions: {
						success: function(data) {
						},
						fail: function(err) {
						}
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.handling_result{
		background: #fff;
		height: 100%;
		.result_box{
			padding:20rpx;
			height: calc(100% - 120rpx);
			.result_item{
				font-size: 30rpx;
				line-height: 56rpx;
			}
			.swiper-box{
				margin: auto;
				width: 500rpx;
				height: 400rpx;
				.swiper-item{

					height:100%;
					image{
						border-radius: 20rpx;
						width:100%;
						height:100%;
					}
				}
			}
		}
		.pending_buttons{
			display: flex;
			justify-content: space-between;
			button{
				margin:0;
				flex:1;
				color:#fff;
				border-radius: 48rpx;
				background: #ee625f;
				&::after{
					border:none;
				}
			}
		}
	}
</style>
